package top.lunarye.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.ToString;

/**
 * 结果统计埋点
 * @author lunar
 * @since 2022-07-19
 */
@Getter
@ToString
@AllArgsConstructor
public enum AnchorState {

    RECEIVE(10, "消息接受成功"),
    DISCARD(20, "消息被丢弃"),
    CONTENT_DEDUPLICATION(30, "消息被内容去重"),
    RULE_DEDUPLICATION(40, "消息被频次去重"),
    SEND_SUCCESS(50, "消息发送成功"),
    SEND_FAIL(60, "消息发送失败")
    ;

    private final Integer code;
    private final String description;

    public static String getDescriptionByCode(Integer code) {
        for (AnchorState anchorState : AnchorState.values()) {
            if (anchorState.getCode().equals(code)) {
                return anchorState.getDescription();
            }
        }
        return "null";
    }
}
